﻿using DevExpress.Xpf.Bars;
using DevExpress.Xpf.Ribbon;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace YmSoft.WPF.WenShiCanShuSheZhi
{
    /// <summary>
    /// 温室Ribbon的门面
    /// </summary>
    public class RoomRibbonBuilder
    {
        public RoomRibbonBuilder(BarManager barManager, RibbonPageGroup ribbonPageGroup)
        {
            this.BarManager = barManager;
            this.RibbonPageGroup = ribbonPageGroup;
        }

        public BarManager BarManager { get; private set; }

        public RibbonPageGroup RibbonPageGroup { get; private set; }

        public RibbonGalleryBarItem RibbonGalleryBarItem { get; private set; }

        public void Build()
        {
            if (RibbonGalleryBarItem != null)
            {
                return;
            }
            RibbonGalleryBarItem = new RibbonGalleryBarItem();
            RibbonGalleryBarItem.Name = "gRoom";
            RibbonGalleryBarItem.Gallery = new Gallery();
            RibbonGalleryBarItem.Gallery.MinColCount = 10;
            RibbonGalleryBarItem.Gallery.ColCount = 10;
            RibbonGalleryBarItem.Gallery.ItemGlyphSize = new System.Windows.Size(24, 24);
            RibbonGalleryBarItem.Gallery.ItemCheckMode = GalleryItemCheckMode.Single;
            RibbonGalleryBarItem.Gallery.AllowHoverAnimation = true;

            var galleryItemGroup = new GalleryItemGroup();
            galleryItemGroup.Caption = "温室";
            var uriSource = new Uri(@"/YmSoft.WPF;component/Res/appbar.home.variant.png", UriKind.Relative);
            var glyph = new System.Windows.Media.Imaging.BitmapImage(uriSource);
            for (int i = 1; i <= 100; i++)
            {
                var galleryItem = new GalleryItem();
                galleryItem.Caption = i.ToString() + "#";
                galleryItem.Glyph = glyph;
                galleryItemGroup.Items.Add(galleryItem);
            }

            RibbonGalleryBarItem.Gallery.Groups.Add(galleryItemGroup);
            this.BarManager.Items.Add(RibbonGalleryBarItem);
            this.RibbonPageGroup.ItemLinks.Add(new BarItemLink() { BarItemName = "gRoom" });

        }
    }
}
